<template>
    <el-row>
        <el-col :span="24">
            <el-form :inline="true"
                :model="newsSearchObj"
                class="search_prod tl">

                <el-form-item label="">
                    <el-input size="small"
                        clearable
                        v-model="newsSearchObj.oid"
                        placeholder="订单号"></el-input>
                </el-form-item>

                <el-form-item label="">
                    <el-input size="small"
                        clearable
                        v-model="newsSearchObj.username"
                        placeholder="会员账号"></el-input>
                </el-form-item>

                <el-form-item label="">
                    <el-input size="small"
                        clearable
                        v-model="newsSearchObj.nickname"
                        placeholder="会员昵称"></el-input>
                </el-form-item>

                <el-form-item label=""
                    class="time_width">
                    <el-date-picker v-model="createTime"
                        type="datetimerange"
                        size="small"
                        align="right"
                        unlink-panels
                        value-format="timestamp"
                        range-separator="-"
                        clearable
                        start-placeholder="开始日期"
                        end-placeholder="结束日期"
                        :picker-options="pickerOptions2">
                    </el-date-picker>
                </el-form-item>

                <el-form-item>
                    <el-button :loading='$store.state.isLoading'
                        size="small"
                        class="top_weiy"
                        type="primary"
                        @click="onSubmit">查询</el-button>
                    <el-button :loading='$store.state.isLoading'
                        size="small"
                        class="top_weiy"
                        type="primary"
                        @click="delSubmit">一键清除</el-button>
                </el-form-item>

            </el-form>
        </el-col>
    </el-row>
</template>
<script>
export default {
    name: "",
    data () {
        return {
            pickerOptions2: {
                disabledDate (time) {
                    return time.getTime() > Date.now();
                }
            },
            newsSearchObj: {
                username: "",
                nickname: "",
                price: "",
                created_time_begin: "",
                created_time_end: ""
            },
            createTime: [],
            optionProps: {
                value: "id",
                label: "title",
                children: "z"
            },
            data: [],
            op: []
        };
    },
    methods: {
        delSubmit () {
            this.newsSearchObj = {
                username: "",
                nickname: "",
                price: "",
                created_time_begin: "",
                created_time_end: ""
            };
            this.$emit("sendSearch", this.newsSearchObj);
        },
        onSubmit () {
            console.log(this.newsSearchObj);
            this.$emit("sendSearch", this.newsSearchObj);
        }
    },
    created () { },
    watch: {
        createTime (val) {
            if (val != null) {
                this.newsSearchObj.created_time_begin = this.$fnc.phptime(val[0]);
                this.newsSearchObj.created_time_end = this.$fnc.phptime(val[1]);
            } else {
                this.newsSearchObj.created_time_begin = "";
                this.newsSearchObj.created_time_end = "";
            }
        }
    }
};
</script>
